import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx/common/routes/app_pages.dart';
import 'package:getx/pages/list_detail/index.dart';


class HomeView extends StatelessWidget {
  const HomeView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("首页"),
        backgroundColor: Colors.blue,
      ),
      body: ListView(
        children: <Widget>[
          ListTile(
            title: const Text("导航-命名路由 home > list"),
            subtitle: const Text('Get.toNamed("/home/list")'),
            onTap: () => Get.toNamed("/home/list"),
          ),
          ListTile(
            title: const Text("导航-命名路由 home > list > detail"),
            subtitle: const Text('Get.toNamed("/home/list/detail")'),
            onTap: () => Get.toNamed("/home/list/detail"),
          ),
          ListTile(
            title: const Text("导航-类对象"),
            subtitle: const Text("Get.to(DetailView())"),
            onTap: () => Get.to(const DetailView()),
          ),
          ListTile(
            title: const Text("导航-arguments传值+返回值"),
            subtitle: const Text(
                'Get.toNamed("/home/list/detail", arguments: {"id": 999})'),
            onTap: () async {
              var result = await Get.toNamed("/home/list/detail",
                  arguments: {"id": 999});
              Get.snackbar("返回值", "success -> ${result["success"]}");
            },
          ),
          ListTile(
            title: const Text("导航-parameters传值+返回值"),
            subtitle: const Text('Get.toNamed("/home/list/detail?id=666")'),
            onTap: () async {
              var result = await Get.toNamed("/home/list/detail?id=666");
              Get.snackbar("返回值", "success -> ${result["success"]}");
            },
          ),

          ListTile(
            title: const Text("导航-中间件-认证Auth"),
            subtitle: const Text('Get.toNamed(AppRoutes.My)'),
            onTap: () => Get.toNamed(AppRoutes.My),
          ),
          ListTile(
            title: const Text("状态管理 - StateObx"),
            subtitle: const Text("Get.to(DetailView())"),
            onTap: () => Get.toNamed(AppRoutes.StateObx),
          ),
          ListTile(
            title: const Text("状态管理 - StateGetx"),
            subtitle: const Text("Get.StateGetx"),
            onTap: () => Get.toNamed(AppRoutes.StateGetx),
          ),
          ListTile(
            title: const Text("状态管理 - StateGetBuilder"),
            subtitle: const Text("Get.StateGetBuilder"),
            onTap: () => Get.toNamed(AppRoutes.StateGetBuilder),
          ),
          ListTile(
            title: const Text("状态管理 - StateValueBuilder"),
            subtitle: const Text("Get.StateValueBuilder"),
            onTap: () => Get.toNamed(AppRoutes.StateValueBuilder),
          ),
          ListTile(
            title: const Text("控制器 - StateWorkers"),
            subtitle: const Text("StateWorkers"),
            onTap: () => Get.toNamed(AppRoutes.StateWorkers),
          ),
          ListTile(
            title: const Text("依赖注入 - StateDependencyPutFind"),
            subtitle: const Text("StateDependencyPutFind"),
            onTap: () => Get.toNamed(AppRoutes.StateDependencyPutFind),
          ),
          const Divider()
        ],
      ),
    );
  }
}
